<?php if(isset($isInsert) && $isInsert){
?>
<script>
	ajax('listContent','<?php echo $this->params['controller'].'/lists/'.$pid?>');
	closeBox('addContent','mainContent');
</script>
<?php
}
else{
?>
<fieldset>
    <legend><?php _resource('add '.$this->params['controller']);?></legend>
<center><div id="message">&nbsp;</div></center>
<?php if($this->Session->read('message')){
	echo '<script>showMessage("addContent","'.$this->Session->read('message').'");</script>';
	$this->Session->delete('message');	
	}?>
<?php if($this->Session->read('error')){
	echo '<script>showMessage("addContent","'.$this->Session->read('error').'",1);</script>';
	$this->Session->delete('error');
}?>
    <form id="adminForm" name="adminForm" method="post" action="<?php echo $this->params['controller'].'/add/'.$pid;?>" onsubmit="onFormSubmit();return false;">
    <?php echo $this->Form->hidden($uses[0].'.image_category_id',array('value'=>$pid));?>
	<table border="0" class="form" style="width:100%">
       	<tr>          
       		<td class="label" align="right" width="100px"><?php _resource('name') ?>
       		
       		</td>
       		<td align="left"><?php echo $this->Form->input($uses[0].'.name',array('onkeyup'=>'onEnterSubmit(this,event,"onFormSubmit()")','class'=>'input_require','label'=>'','size'=>60,'maxlength'=>255));?></td>           
        </tr>
       
<tr>          
       		<td class="label" align="right" width="100px"><?php _resource('new image') ?>
       		
       		</td>
       		<td align="left">
       			<?php echo $this->Form->input($uses[0].'.image',array('type'=>'hidden','class'=>'input','label'=>'','size'=>60,'maxlength'=>255));?>
       			<div id="fine-uploader-thumb">
       				<?php if(isset($this->data[$uses[0]]['image'])&& !empty($this->data[$uses[0]]['image'])){?>
		       			<img style="opacity: 1;" src="<?php echo $this->webroot.'uploaded/'.$uses[0].'/thumb/'.$this->data[$uses[0]]['image'] ?>">
		       		<?php }?>
       			</div>
       			<div id="fine-uploader" style="margin-top:10px"></div>   
        	</td>
        </tr>
        
        <tr>          
       		<td class="label" align="right" width="100px"><?php _resource('url') ?>
       		
       		</td>
       		<td align="left"><?php echo $this->Form->input($uses[0].'.url',array('onkeyup'=>'onEnterSubmit(this,event,"onFormSubmit()")','class'=>'input_require','label'=>'','size'=>60,'maxlength'=>255));?></td>           
        </tr>
        
         <tr>          
       		<td class="label" align="right" width="100px"><?php _resource('type') ?>
       		
       		</td>
       		<td align="left"><?php echo $this->Form->input($uses[0].'.type', array('type'=>'select','options'=>$types,'empty'=>false,"class"=>"inputbox","label"=>"","div"=>"","error"=>""));?></td>           
        </tr>
        
         
	</table>
	<center>
    <div style="width:130px">
          <div class="button"><a onclick="onFormSubmit()" href="javascript:;" title="<?php echo _resource('save') ?>"  > <span class="icon-32-save"> </span></a> </div>         
          <div class="button"><a onclick="resetForm('adminForm')" href="javascript:;" title="<?php echo _resource('reset') ?>"  > <span class="icon-32-back"> </span></a> </div>
          <div class="button"><a onclick="closeBox('addContent','mainContent')" href="javascript:;" title="<?php echo _resource('close') ?>"  > <span class="icon-32-cancel"> </span></a> </div>
    </div>
    </center>
      </form>
</fieldset>


<script>
function onFormSubmit(){
	deactivateEditors();
	submitForm('adminForm','addContent');
}
activateFineUploader('fine-uploader','image','<?echo $uses[0]?>','fine-uploader-thumb','<?php echo $uses[0]?>Image');
$('#<?php echo $uses[0]?>Name').focus();

scrollTopTo('addContent');	
</script>
<?php }?>
